add_definitions(-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_FROM_BYTEARRAY)
include(../cmake/find-modules/FindXCB.cmake)
set(XCB_LIBS
        xcb
        xcb-util
        xcb-damage
        xcb-image
        xcb-composite
        xcb-shape
        )
find_package(KF5WindowSystem)

include_directories(../common)
set(XEMBED_SNI_PROXY_SOURCES
        main.cpp
        fdo-selection-manager.cpp
        fdo-selection-manager.h
        sni-proxy.cpp
        sni-proxy.h
        xtest-sender.cpp
        xtest-sender.h
        xcb-utils.h
        ../common/dbus-types.cpp
        ../common/dbus-types.h
        ../common/typedefs.h
        )

qt_add_dbus_adaptor(XEMBED_SNI_PROXY_SOURCES ../dbus/org.kde.StatusNotifierItem.xml sni-proxy.h SNIProxy)
set(statusnotifierwatcher_xml ../dbus/org.kde.StatusNotifierWatcher.xml)
set_source_files_properties(${statusnotifierwatcher_xml} PROPERTIES
        NO_NAMESPACE false
        INCLUDE "../common/dbus-types.h"
)
qt_add_dbus_interface(XEMBED_SNI_PROXY_SOURCES ${statusnotifierwatcher_xml} statusnotifierwatcher_interface)

add_executable(xembed-sni-proxy ${XEMBED_SNI_PROXY_SOURCES})
target_include_directories(xembed-sni-proxy PUBLIC ../common)

set_package_properties(XCB PROPERTIES TYPE REQUIRED)

target_link_libraries(xembed-sni-proxy
        Qt${QT_VERSION_MAJOR}::Core
        Qt${QT_VERSION_MAJOR}::DBus
        Qt${QT_VERSION_MAJOR}::X11Extras
        Qt${QT_VERSION_MAJOR}::Gui
        KF5::WindowSystem
        ${XCB_LIBS}
        X11::Xtst
        )
if (QT_MAJOR_VERSION EQUAL "5")
    target_link_libraries(xembed-sni-proxy Qt::X11Extras)
else()
    target_link_libraries(xembed-sni-proxy Qt::GuiPrivate)
endif()

install(TARGETS xembed-sni-proxy DESTINATION /usr/bin)
install(FILES xembed-sni-proxy.desktop DESTINATION /etc/xdg/autostart)
